<#assign menuId=4>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>大货订单-${Application.systemName!}</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- font Awesome -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Ionicons -->
        <link href="../css/ionicons.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="../css/bootstrap-select.css">
		<!--datetimepicker-->
		<link rel="stylesheet" type="text/css" href="../css/datetimepicker/bootstrap-datetimepicker.min.css"/>
        <link href="../css/myself.css" rel="stylesheet" type="text/css" />
	  
    	<style type="text/css">
    		*{
    			margin: 0;
    			padding: 0;
    		}
    		.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
			    vertical-align: middle;
			}
    		ul li{
    			list-style: none;
    			margin-top: 10px;
    		}
    		.conter_jiben{
    			margin-bottom: 10px; 
    		}
    		.pull-left{
    			border-left: 6px solid #3882FF;
    			padding: 0 5px;
    		}
    		.bold{
    			font-size: 14px;
    			font-weight: bold;
    		}
    		.custormView{
    			margin-top: 10px;
    		}
	    	.inpt tr td input {
			    width: 100%;
			    height: 100%;
			    border: 0;
			    font-size: 12px;
			    text-align: center;
			}
	        label{
	        	display: inline-block;
	        	margin: 0;
	        }
	        .row{
	        	padding: 0 0 0 20px;
	        }
	        .box1{}
        .label_text{padding-bottom: 1em;}
        .r_radio_warp{height: 3rem;}
        .r_radio{width: 30%;text-align:center}
        .r_radio input{margin-right: 1rem;}
        .r_textarea{width: 100%;resize: none;border: 1px solid #999;padding: 1em 1em;}
        .r_btn_wrap{margin-top: 1rem;}
        .r_check{height: 2em;line-height: 2em;}
        .btn{padding: 6px 30px;}
        .box3{width: 50%}
        .box3 .r_btn_wrap{width: 50%;margin: 0 auto;}
        .box5 .r_btn_wrap{margin-top: 3rem;}
        .box .title{height: 2.5em;}
        .stopWarn p{color: #999;}
        .box6 p{margin-bottom: 10px;}
        .stopWarn h1{font-size: 18px;line-height: 2em;height: 2em;}
        .p_center{text-align: center;}
        .btn_white{background:white;border: 1px solid #cfd8e3;color: #747e8d;}
        .btn_white:hover{background:white;border: 1px solid #3794ff;color: #56a4ff;}
        .box7{width: 80%;}
    	
    	
   		.ol_left{
            width: 100%;
            height: 30px;
            line-height: 30px;
            padding: 0;
        }
        .ol_left>li{
            float: left;
            margin-right: 5px;
        }
        .ol_left li, .ol_left{
        	margin-bottom: 0;
        }
        
        /* 上传文件样式 */
			.file {
			    position: relative;
			    display: inline-block;
			    background: #D0EEFF;
			    border: 1px solid #99D3F5;
			    border-radius: 4px;
			    padding: 4px 12px;
			    overflow: hidden;
			    color: #1E88C7;
			    text-decoration: none;
			    text-indent: 0;
			    line-height: 20px;
			}
			.file input {
			    position: absolute;
			    font-size: 100px;
			    right: 0;
			    top: 0;
			    opacity: 0;
			}
			.file:hover {
			    background: #AADFFD;
			    border-color: #78C3F3;
			    color: #004974;
			    text-decoration: none;
			}
			#fileName, #fileName1{
	        	color: #3882ff;
	        }
    	</style>
    </head>
    <body class="skin-blue">
        <!-- header logo: style can be found in header.less -->
         <#include "../header.html"/>
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- Left side column. contains the logo and sidebar -->
            <#include "../menu.html"/>

            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="right-side">
            	<section class="content-header">
                    <h1>创建大货订单</h1>
                    <ol class="ol_left">
		                <li>当前位置：</li>
		                <li><a href="list?pageNo=1">大货订单</a></li>
		                <li>> 创建大货订单</li>
		            </ol>
		            <span style="position:absolute; top:20px; right:20px;">  
                   		<!-- <span class="six-font">设计款数5款   </span> -->
                   		<span class="six-font">共${proofingOrderResult.proofingPatternResults?size}件</span>
                                 <#if proofingOrderResult.enddateCnt??>
                                      <#if proofingOrderResult.enddateCnt gt 0>
                                      <span class="six-font ">剩余 <span>${proofingOrderResult.enddateCnt?abs}</span>天</span>
                                      </#if>
                                      <#if proofingOrderResult.enddateCnt lt 0>
                                      <span class="six-font red">超期<span>${proofingOrderResult.enddateCnt?abs}</span>天</span>
                                      </#if>
                                      <#if proofingOrderResult.enddateCnt == 0>
                                      <span class="six-font ">剩余 <span>${proofingOrderResult.enddateCnt?abs}</span>天</span>
                                      </#if>
                                    </#if>
                    </span>
                    <hr style="margin: 10px 0 0 0" />
               </section>
                <!-- Content Header (Page header) -->
                <section class="content">
                    <div class="row">
                    	<div class="col-md-12">
                            <div class="box">
			                    <div class="clearfix center">
			                    	<span class="pull-left bold">订单信息</span>
	                                          <a href="javascript:;" class="bule fl up-div" style="font-size: 12px">查看详情<i class="sq-icon"></i></a>
				                    
			                    </div>
			                    <div class="center clearfix">
                                <div class="conter_jiben col-md-12 marginTOP10 bold no-padding" style="margin-top: 20px;">订单基本信息</div>
                                <table class="table table-bordered">
                                    <tr>
                                        <td class="text-center no-border" width="10%">订单编号:</td>
                                        <td class="no-border" width="40%">${proofingOrderResult.code}</td>
                                        <td class="text-center no-border" width="10%">订单创建时间:</td>
                                   		<td class="no-border" width="40%">${proofingOrderResult.createAt?string("yyyyMMdd HH:mm")}</td>
                                    </tr>
                                </table>
                                <div class="conter_jiben col-md-12 bold no-padding">客户信息</div>
                                <table class="table table-bordered">
                                    <tr>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">客户编号</td></tr>
                                        		<tr><td style="border: 0;">客户名称</td></tr>
                                        		<tr><td style="border: 0;">客户分类</td></tr>
                                        		<tr><td style="border: 0;">网&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址</td></tr>
                                        		<tr><td style="border: 0;">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</td></tr>
                                        	</table>

                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.code!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.fullname}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.category!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.web!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.memo!}</td></tr>
                                        	</table>
                                        </td>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">客户等级</td></tr>
                                        		<tr><td style="border: 0;">客户简称</td></tr>
                                        		<tr><td style="border: 0;">公司地址</td></tr>
                                        		<tr><td style="border: 0;">收件地址</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.level!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.abbreviation!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.province!} ${proofingOrderResult.customer.city!} ${proofingOrderResult.customer.area!} ${proofingOrderResult.customer.detailAddress!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.deliveryAddress!}</td></tr>
                                        	</table>
                                        </td>
                                    </tr>
                                    <#list proofingOrderResult.customer.contacts as contact>
                                    <tr>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">联系人姓名</td></tr>
                                        		<tr><td style="border: 0;">邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">&nbsp;${contact.linkman!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${contact.email!}</td></tr>
                                        	</table>
                                        </td>
                                         <td class="text-center" width="10%">
                                         	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">联系方式</td></tr>
                                        		<tr><td style="border: 0;">职位/部门</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">&nbsp;${contact.contact!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${contact.deptPosition!}</td></tr>
                                        	</table>
                                        </td>
                                    </tr>
                                    </#list>
                                </table>
                                <div class="conter_jiben col-md-12 marginTOP10 bold no-padding">产品信息</div>
                                <table class="table table-bordered">
                                    <tr>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">产品品类</td></tr>
                                        		<tr><td style="border: 0;">附件</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr>
	                                        		<td style="border: 0;">
	                                        			<#if proofingOrderResult.customer.productCategory?size!=0>
					                    				<#list proofingOrderResult.customer.productCategory as productCategory>
					                    					 ${productCategory} 
					                    				</#list>
					                    				<#else>/
					                    				</#if>
	                                        		</td>
                                        		</tr>
                                        		<tr>
                                        			<td style="border: 0;">
                                        				<#if proofingOrderResult.customer.attachment?size!=0>
					                    				<#list proofingOrderResult.customer.attachment as attach>
					                    				
					                    				<span id="fileName1">${attach.businessFile?substring(13)}</span>
					                    				<a href="../customer/downFile?filename=${attach.businessFile}" class="down"><i class="iconfont down-i"></i>点击下载</a>	
					                    				
					                    				
					                    				
					                    				<!-- ${attach.businessFile?substring(13)}<a href="../customer/downFile?filename=${attach.businessFile}">点击下载</a> -->
					                    				</br>
					                    				</#list>
					                    				<#else>/
					                    				</#if>
                                        			</td>
                                        		</tr>
                                        	</table>
                                        </td>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">风格</td></tr>
                                        		<tr><td class="no-border">&nbsp;</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr>
                                        			<td style="border: 0;">
                                        				<#if proofingOrderResult.customer.styleLabel?size!=0>
						                    			<#list proofingOrderResult.customer.styleLabel as styleLabel>
						                    				<span class="biaoqian">${styleLabel!}</span>
						                    			</#list>
						                    			<#else>/
						                    			</#if>
                                        			</td>
                                        		</tr>
                                        		<tr><td class="no-border">&nbsp;</td></tr>
                                        	</table>
                                        </td>
                                    </tr>
                                </table>
                                <div class="conter_jiben col-md-12 marginTOP10 bold no-padding">销售信息</div>
                                <table class="table table-bordered">
                                    <tr>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">目标人群</td></tr>
                                        		<tr><td style="border: 0;">销售价格</td></tr>
                                        		<tr><td style="border: 0;">上新频率</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.targetConsumer!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.salePrice!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.updateFrequency!}</td></tr>
                                        	</table>
                                        </td>
                                        <td class="text-center" width="10%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">销售渠道</td></tr>
                                        		<tr><td style="border: 0;">预计年销售额</td></tr>
                                        		<tr><td style="border: 0;">上新数量</td></tr>
                                        	</table>
                                        </td>
                                        <td width="40%">
                                        	<table class="table no-margin no-padding">
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.saleChannel!}</td></tr>
                                        		<tr><td style="border: 0;">&nbsp;${proofingOrderResult.customer.saleAmount!}</td></tr>
                                        		<tr><td style="border: 0;">
                                        		<#if proofingOrderResult.customer.updateCount??>
                                        		${proofingOrderResult.customer.updateCount!}款/次
                                        		</#if>
                                        		</td></tr>
                                        	</table>
                                        </td>
                                    </tr>
                                </table>
                                <div class="conter_jiben col-md-12 marginTOP10 bold no-padding">客户需求</div>
                                <table class="table table-bordered">
                                    <tr>
                                        <td class="text-center" width="10%">
                                            需求描述
                                        </td>
                                        <td width="90%">&nbsp;
                                           ${proofingOrderResult.requirement!}
                                        </td>
                                       
                                    </tr>
                                </table>
                            </div>
                                <div class="center">
                                    <div class="bold" style="margin-top: 10px">填写基本信息</div>
                                    <form id="form">
                                    <table class="table table-bordered custormView">
                                        <tr>
                                            <td class="text-center" width="10%">
                                            	<label class="red">*</label>
                                           		 客户名称
                                            </td>
                                            <td colspan="3" width="90%">
                                            
                                            	${customer.fullname!}
                                            </td>
                                          
                                        </tr>
                                        <tr>
                                        	<td class="text-center" width="10%">
                                        		<label class="red">*</label>
                                        		截止时间
                                        	</td>
                                        	<td width="40%">
				
                <div id="datetimepicker1" class="input-group date form_datetime col-md-8" >
                    <input class="form-control" size="60" type="text" name="enddate" value="">
					<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                </div>
          
                                        	</td>
                                        	<td class="text-center" width="10%">合同附件</td>
                                        	<td  width="40%">
                                        		<div class="file_fa">
                                    					<a href="javascript:;" class="file">
														    <input  type="file"  name="file"   onchange="document.getElementById('fileName').innerHTML=this.value">上传附件
														</a>
														<span id="fileName"></span>
                                    				</div>
                                        	</td>
                                        </tr>
                                        <tr>
                                        	<td class="text-center" width="10%">客户需求</td>
                                        	<td colspan="3">
                                        		<div class="form-group textarea">
		                                            <textarea style="font-size: 12px" class="form-control" rows="3" name="requirement" placeholder="">${proofingOrderResult.requirement!}</textarea>
		                                        </div>
                                        	</td>
                                        </tr>
                                    </table>
                                    </form>
		                            <div class="clearfix">
		                                <span class="pull-left bold no-border no-padding">选择打样款型</span>
		                            </div>
		                            <#if proofingOrderResult??>
                                    <#list proofingOrderResult.proofingPatternResults as proofingPattern>
                                    <table class="table table-bordered custormView">
                                        <tr>
                                            <td colspan="7"  class="left-text">
                                                <span style="font-weight: bold;">${proofingOrderResult.createAt?string("yyyy/MM/dd")}</span>
                                                <span style="font-weight: bold;">订单号：${proofingPattern.code!}</span>
                                                <a href="../orderpattern/detail?id=${proofingPattern.orderPatternId}" class="fr bule-border">查看明细</a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="60%">
                                                <span class="Design_draft"><img src="${Application.accessFileUrl}/${proofingPattern.mainImage!}" alt="" /></span>
                                            </td>
                                            <td class="rel" colspan="6" style="vertical-align: top;">
                                                <i class="design-icon"></i>
                                                <div class="design-text">
                                                	<p>项目经理报价： <span>成本价：${proofingPattern.costPrice!}</span></p>
                                                	<p>
	                                                	<span>最低销售价：${proofingPattern.minSalePrice!}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	                                                	<span>建议零售价：${proofingPattern.salePrice!}</span>
                                                	</p>
                                                    <p>设计编号：<span>${proofingPattern.code!}<span></p>
                                                    <p>款号：<span>${proofingPattern.patternNo!}</span></p>
                                                    <p>年份：<span>${proofingPattern.period!}</span></p>
                                                    <p>季节：<span>${proofingPattern.season!}</span></p>
                                                    <p>性别：<span>${proofingPattern.sex!}</span></p>
                                                    <#list proofingPattern.styleLabelConstants as constant>
                                                    <span class="bule-border">${constant.name!}</span>
                                                    </#list>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" style="text-align: center; background: rgb(246,246,246);">
                                                <a href="javascript:addAmount(${proofingPattern_index});">选择此款，填写数量 </a>
                                            </td>
                                        </tr>
                                       	<tr id="patternAmount_${proofingPattern_index}" style="display:none">
                                       		<td colspan="2" class="center_list">
                                       			<table class="table table-bordered inpt" id="tab_${proofingPattern.orderPatternId}" >
                                       				<tr>
                                       					
                                       					<th>颜色</th>
                                       					<th>XS</th>
                                       					<th>S</th>
                                       					<th>M</th>
                                       					<th>L</th>
                                       					<th>XL</th>
                                       					<th>XXL</th>
                                       					<th></th>
                                       				</tr>
                                       			
                                       				
                                       					<tr>
                                       					<td colspan="8">
                                       						<a href="javascript:addRow(${proofingPattern.orderPatternId})">+添加一行</a>
                                       					</td>
                                       				</tr>
                                       			</table>
                                       		</td>
                                       	</tr>
                                       	<tr  id="patternAmount_sum_${proofingPattern_index}" style="display:none">
	                                        <td colspan="2"  class="right-text">
	                                            <span id="patternAmount_sum_span_${proofingPattern.orderPatternId}" class="pull-right">总计件数：<span id="count">0</span>件</span>
	                                        </td>
	                                    </tr>
                                    </table>
                                    </#list>
                                    </#if>
                                    <p>
                                    	<button type="button" id="addbtn" class="btn btn-primary" style="margin-right: 10px;">共<span id="pattern_count">0</span>款&nbsp;&nbsp;&nbsp;&nbsp;确定创建</button>
                                    	<button type="button" class="btn btn-default" id="repeal">取消</button>
                                    </p>
                        		</div>
                            </div><!-- /.box -->

                            
                        </div><!-- /.col -->
                        
                    </div><!-- /.row -->
                    
                </section>

                <!-- Main content -->
                <section class="content">
					
				
                </section><!-- /.content -->
                
                
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->


        <!-- jQuery 2.0.2 -->
        <script src="../js/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="../js/bootstrap.min.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="../js/AdminLTE/app.js" type="text/javascript"></script>
        <!-- AdminLTE for demo purposes -->
      
    	<!--datepickes-->
		<script src="../js/plugins/datetimerpicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
		<script src="../js/plugins/datetimerpicker/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
		<script type="text/javascript" src="../js/bootstrap-select.js"></script> 
		<script src="../js/jquery.form.min.js"></script>
    </body>
    <script type="text/javascript">
    	
			$(function() {
			    $('#datetimepicker1').datetimepicker({
			    	format: 'yyyy-mm-dd hh:00',
			       	language:  'zh-CN',  
		            weekStart: 1,  
		            todayBtn:  1,  
		            autoclose: 1,  
		            todayHighlight: 1,  
		            startView: 2,  
		            forceParse: 0,  
		            showMeridian: 0,
		            minView: 1,
		            startDate: new Date()
			    });
		
			

			    $("#addbtn").click(function(){ 
			    	if(!checkCount()) return false;
			    	if(!checkDate()) return false;
			    	if(!checkColor()) return false;
			    	var dataList = new Array();
			    	<#if proofingOrderResult??>
			    	<#list proofingOrderResult.proofingPatternResults as proofingPattern>
				    	var len = $("#tab_${proofingPattern.orderPatternId}").find("tr").length;
						for(var i =1;i<len-1;i++){
							var data = {};
							data["orderPatternId"] = ${proofingPattern.orderPatternId};
							for(var j=0;j<7;j++){
								var name = $("#tab_${proofingPattern.orderPatternId}").find("tr").eq(i).find("td").eq(j).find("input").attr("name");
								var val = $("#tab_${proofingPattern.orderPatternId}").find("tr").eq(i).find("td").eq(j).find("input").val();
								data[name] =val;
							}
							dataList.push(data);
						}
			    	</#list>
			    	</#if>
			    	$("#form").ajaxSubmit({
	                    type: "POST",
	                    dataType: "json",
	                    url: "insert",
	                    data: {patternSizeList:dataList,orderId:${orderId}},
	                    success : function(map) {  
	    	                if(map.head.respCode=="0000000"){
	    	                	alert("保存成功");
	    	                	window.location.href="list";
	    	                }else{
	    	                	alert(map.body);
	    	                }
	    	            },  
	    	            error : function(map) {  
	    	                alert("出现错误，请刷新页面");  
	    	            }  

	                });
		      	  });
			    $("#customerId").val(${proofingOrderResult.customerId});
			});
			function addAmount(index){
				var count=$('#pattern_count').html();
		    	count=parseInt(count);
		    	if(document.getElementById("patternAmount_"+index).style.display=="none"){
		    		document.getElementById("patternAmount_"+index).style.display="";
		    		document.getElementById("patternAmount_sum_"+index).style.display="";
		    		$('#pattern_count').html(++count);
		    	}else{
		    		document.getElementById("patternAmount_"+index).style.display="none";
		    		document.getElementById("patternAmount_sum_"+index).style.display="none";
		    		$('#pattern_count').html(--count);
		    	}
		    }
			
			function addRow(id){
				var len = $("#tab_"+id).find("tr").length -2;
				$("#tab_"+id+" tr:eq("+len+")").after('<tr><td><input name="color" type="text"/></td>'+
				'<td><input name="xsAmount" type="text"/></td>'+
				'<td><input name="sAmount" type="text"/></td>'+
				'<td><input name="mAmount" type="text"/>'+
				'</td><td><input name="lAmount" type="text"/></td>'+
                '<td><input name="xlAmount" type="text"/></td>'+
                '<td><input name="xxlAmount" type="text"/></td>'+
                '<td><div id="del_'+id+"_"+len+'" class="red_circle"><div></div></div></td></tr>');
				//$("#patternAmount_sum_span_"+id).text("总计件数："+($("#tab_"+id).find("tr").length -2)+"件");
				$("#tab_"+id+" tr:eq("+len+")").next().find('input:not(:first)').change(calculate).focus(getValue);
				$("#del_"+id+"_"+len).click(function(){
					var inputs=$(this).parent().prevAll(':not(:last)').find('input');
					var span=$(this).parents('table').eq(1).find('#count');
					var total=span.html();
					for(var i=0;i<inputs.length;i++){
						var count=inputs.eq(i).val();
						if(!count||isNaN(count)) continue;
						total-=count;
					}
					span.html(total);
					$(this).parent().parent().remove();
					//getPatternCnt();
				})
				//getPatternCnt();
			}
			
			function getPatternCnt(){
				var cnt = 0;
				<#if proofingOrderResult??>
				<#list proofingOrderResult.proofingPatternResults as proofingPattern>
				var len = $("#tab_${proofingPattern.orderPatternId}").find("tr").length;
				if(len>2){
					cnt++;
				}
				</#list>
				</#if>
				$("#addbtn").html("共"+cnt+"款&nbsp;&nbsp;&nbsp;&nbsp;确定创建");
			}
			
			function calculate(){
				var count=$(this).val();
				var span=$(this).parents('table').eq(1).find('#count');
				var total=span.html();
				if(count&&!isNaN(count)){
					count=parseInt(count);
					total=parseInt(total)+count;
				}else{
					if(count){
						$(this).val('');
						alert('请输入数字');
					}
				}
				if(model.value&&!isNaN(model.value))
					total-=model.value;
				span.html(total);
			}
			
			model={};
			
			function getValue(){
				model.value=$(this).val();
			}
			
			$(function(){
				$('.center').eq(1).hide();
				$('.center').eq(1).prev().children('.bule').click(toggleConter);
            })
            
            function toggleConter(){
	           	 $('.center').eq(1).toggle();
	           	 if($('.center').eq(1).css('display')=='none')
	           		 $(this).html('查看详情');
	           	 else
	           		 $(this).html('收起');
            }
			
			$(function(){
				$('#repeal').click(function(){
					confirm('确定放弃创建大货订单？放弃后当前填写的资料将无法保存',function(isConfirm){
						if(isConfirm){
							history.back();
						}
					});
				});
			})
			
			function checkCount(){
				var spans=$('table').find('#count');
				for(var i=0;i<spans.length;i++){
					var count=spans.eq(i).html();
					if(count) return true;
				}
				alert('大货数量为0');
				return false;
			}
			
			function checkDate(){
				var date=$('[name=enddate]').val();
				if(!date){
					alert('截止时间未填');
					return false;
				}
				var reg=/^\w{4}-\w{2}-\w{2} \w{1,2}:\w{2}$/;
				if(!reg.test(date)){
					alert('截止时间不符');
					return false;
				}
				return true;
			}
			
			function checkColor(){
				var inputs=$('[name=color]');
				for(var i=0;i<inputs.length;i++){
					if(!inputs.eq(i).val()){
						alert('颜色未填写');
						return false;
					}
				}
				return true;
			}
    </script>
</html>
